<template>
    <div>



        <div @click="selectdata()">筛选题库</div>

        <el-dialog title="筛选题库" :visible.sync="dialogFormVisible">

            <template>
                <div style="margin-top: 20px">
                    <!-- <div style="margin: 10px">知识点</div>
                    <el-radio-group v-model="titledata"   v-for="o in titledata" :key="o.id">
                        <el-radio-button label="{{o.id}}">{{o.id}}</el-radio-button>

                    </el-radio-group> -->
                </div>
                <div style="margin-top: 20px">
                    <div style="margin: 10px">难易程度</div>
                    <el-radio-group v-model="selecttwo" size="medium">
                        <el-radio-button label="全部"></el-radio-button>
                        <el-radio-button label="简单"></el-radio-button>
                        <el-radio-button label="适中"></el-radio-button>
                        <el-radio-button label="困难"></el-radio-button>
                    </el-radio-group>
                </div>

            </template>

            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="select">确 定 </el-button>
            </div>
        </el-dialog>

        <template>

        </template>

        <el-card class="box-card" v-for="o in ques" :key="o.id">
            <div slot="header" class="clearfix">
                <span>[题目编号.{{ o.qid +"]"+o.title}}</span>
                <el-button @click="tomy(o)" style="float: right; padding: 3px 0" type="text">添加到我的题库</el-button>
            </div>
            <div  class="text item">
                A.{{ o.sa }}
            </div>
            <div  class="text item">
                B.{{ o.sb }}
            </div>
            <div  class="text item">
                C.{{ o.sc}}
            </div>
            <div  class="text item">
                D.{{ o.sd }}
            </div>
            <div  class="text item">
                正确答案.{{ o.sw }}
            </div>

            <div  class="text item">
                知识点: <el-tag type="success">{{ o.kown }}</el-tag> 难易程度: <el-tag type="info">{{o.degree}}</el-tag>
            </div>
            
        </el-card>




    </div>
</template>

<script>

export default {
    data() {
        return {
            titledata:[],
            dialogFormVisible: false,
            addpersionques:{
                qid:1,
                userid:123123
            },
            selecttwo: '全部',
            ques:[{
                qid:null,
                title:"null",
                sa:"null",
                sb:"null",
                sc:"null",
                sd:"null",
                sw:"null",
                konw:"null",
                Degree:"null"
            }
        
        ]


        };
    },
    created(){
        this.pushalldata()
        var that = this
            this.$axios.get('/title/gettitle', {
            }).then(function (response) {
                console.log(response);
             
                that.titledata = response.data.data
             
            })
                .catch(function (error) {
                    console.log(error);
                   
                });
    },
    methods: {
        open1() {
            this.$message({
                message: '操作成功!',
                type: 'success'
            });
        },
        open2() {
            this.$message({
                message: '操作失败'
            });
        },
        tomy(o){
            console.log(o);
            var that=this
            this.addpersionques.qid=o.qid

            this.$axios.post('/personques/add', {
                qid:that.addpersionques.qid,
                userid:that.addpersionques.userid
            }).then(function (response) {
                console.log(response.data);

                that.open1();
             
            })
                .catch(function (error) {
                    console.log(error);
                    
                });

        },
        select() {


            var that = this

            if(this.selecttwo=='全部'){
                this.pushalldata()
                this.dialogFormVisible = false

            }else{

            this.$axios.get('/question/getsome', {
                params:{
                    // know:that.selectone,
                    drgee:that.selecttwo
                }
            }).then(function (response) {
                console.log(response.data);
                that.ques = response.data.data

                that.dialogFormVisible=false
                that.open1();
             
            })
                .catch(function (error) {
                    console.log(error);
                    
                });
            }

         },
        selectdata() {
            this.dialogFormVisible = true
        },

        pushalldata(){
            var that = this
            this.$axios.get('/question/getall', {
            }).then(function (response) {
                console.log(response.data);
                
                
                that.ques = response.data.data
             
            })
                .catch(function (error) {
                    console.log(error);
                    that.open2();
                });
        }

    }

}
</script>

<style >
.text {
    font-size: 14px;
}

.item {
    padding: 10px 0;
}

.box-card {
    margin: 20px auto;
    width: 1550px;
}
</style>